<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title></title>

	<style type="text/css">

	</style>
</head>

<body>
	<form action="" method="post">

		<input type="button" value="全选" onclick="a()" />
		<input type="button" value="全不选" onclick="b()" />
		<input type="button" value="反选" onclick="c()" />
		<br />
		<input type="checkbox" name="love" id="" value="" /><br />
		<input type="checkbox" name="love" id="" value="" /><br />
		<input type="checkbox" name="love" id="" value="" /><br />
		<input type="checkbox" name="love" id="" value="" /><br />
		<input type="checkbox" name="love" id="" value="" /><br />
	</form>
</body>
<!-- 首先弄好 全选 反选 和不全选 设置他们的函数  然后链接起来 -->
<script type="text/javascript">
	//全选函数
	function a() {
		var loves = document.getElementsByName("love");
		for (var i = 0; i < loves.length; i++) {
			loves[i].checked = true;
		}
	}

	//全不选函数
	function b() {
		var loves = document.getElementsByName("love");
		for (var i = 0; i < loves.length; i++) {
			loves[i].checked = false;
		}
	}
	//反选
	function c() {
		var loves = document.getElementsByName("love");
		for (var i = 0; i < loves.length; i++) {
			loves[i].checked = !loves[i].checked;

		}
	}
</script>

</html>